﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MetaCollection.Framework.Model
{
	[Flags]
	public enum LoadOptions
	{
		None = 0,
		/// <summary>
		/// Unique Identifier of this Item
		/// </summary>
		Id = 1,
		/// <summary>
		/// External Identifier associated with this item record
		/// </summary>
		ExternalId = 1 << 1,
		/// <summary>
		/// The Unique Identifier of the Parent of this Item
		/// </summary>
		ParentId = 1 << 2,
		/// <summary>
		/// Version number of this item
		/// </summary>
		Version = 1 << 3,
		/// <summary>
		/// Parent version this instance was derived from
		/// </summary>
		LeftVersion = 1 << 4,
		/// <summary>
		/// Optional additional parent version this instance was derived from
		/// </summary>
		RightVersion = 1 << 5,
		/// <summary>
		/// An identifier that denotes who created this version.  Typically
		/// this would be the Principal.Identity.Name
		/// </summary>
		CreatedBy = 1 << 6,
		/// <summary>
		/// An optional comment given when this version was created.
		/// </summary>
		Comment = 1 << 7,
		/// <summary>
		/// Name Identifier as represented in a structure URI segment
		/// </summary>
		Name = 1 << 8,
		/// <summary>
		/// Indicates this item represents a published copy
		/// </summary>
		Published = 1 << 9,
		/// <summary>
		/// MIME Type of this item.
		/// </summary>
		MimeType = 1 << 10,
		/// <summary>
		/// Model Specification Id for this item.
		/// </summary>
		Specification = 1 << 11,
		/// <summary>
		/// Last modified date/time
		/// </summary>
		LastModified = 1 << 12,
		/// <summary>
		/// Item Path href
		/// </summary>
		Href = 1 <<13,
		/// <summary>
		/// Additional item properties
		/// </summary>
		Properties = 1 << 14,
		/// <summary>
		/// Item Access List Entries
		/// </summary>
		AccessClaims = 1 << 15,
		/// <summary>
		/// Relationships owned by this item
		/// </summary>
		Relationships = 1 << 16,
		/// <summary>
		/// An identifier that represents the set of AccessClaims used on the item.
		/// </summary>
		ItemClaimId = 1 << 17,
		/// <summary>
		/// Standard set of item information required for a reference during path resolution.
		/// </summary>
        ItemReference = Id | Name | Specification | ItemClaimId | AccessClaims,
		/// <summary>
		/// Minimum set of item infomration required for creating an item reference (ParentId, Name, MimeType, Specification, CreatedBy).
		/// </summary>
		ItemCreateReference = ParentId | Name | MimeType | Specification | CreatedBy,
		/// <summary>
		/// Complete set of data
		/// </summary>
        ItemComplete = Id | ExternalId | Name | ParentId | Version | LeftVersion | RightVersion | CreatedBy | Comment | Published | MimeType | Specification | LastModified | ItemClaimId | Properties | AccessClaims | Relationships | Href
	}

	public static class LoadOptionExtensions
	{
		public static bool IsSet(this LoadOptions options, LoadOptions opt)
		{
			return (options & opt) == opt;
		}

		public static bool IsNotSet(this LoadOptions options, LoadOptions opt)
		{
			return (options & (~opt)) == 0;
		}

		public static LoadOptions Set(this LoadOptions options, LoadOptions opt)
		{
			return options | opt;
		}

		public static LoadOptions Clear(this LoadOptions options, LoadOptions opt)
		{
			return options & (~opt);
		}
	}
}
